﻿@using DotNetClub.Web.ViewModels.Topic
@model PostViewModel

<script src="~/lib/editor.md/editormd.min.js"></script>
<link href="~/lib/editor.md/css/editormd.min.css" rel="stylesheet" />

<div class="col-md-9">
    <div class="panel panel-default">
        <div class="panel-heading">
            <ol class="breadcrumb">
                <li><a asp-action="Index" asp-controller="Home">首页</a></li>
                <li>@(Model.IsNew ? "发布话题" : "编辑话题")</li>
            </ol>
        </div>
        <div class="panel-body">
            <form method="post" asp-antiforgery="true">
                <div class="form-group form-inline">
                    <label class="control-label">选择版块:</label>
                    <select name="Category" asp-items="@Model.CategoryList" class="form-control">
                        <option>请选择</option>
                    </select>
                </div>
                <div class="form-group">
                    <input name="Title" type="text" class="form-control" placeholder="标题字数10字以上" value="@Model.Model.Title" />
                </div>
                <div class="form-group">
                    <div id="txtContent">
                        <textarea>@Model.Model.Content</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>

<div class="col-md-3">
    @Html.Partial("_Grammer")

    @Html.Partial("_Guide")
</div>

<script type="text/javascript">
    var editor;

    $(function () {
        editor = editormd("txtContent", {
            name: "Content",
            width: "100%",
            height: 400,
            syncScrolling: "single",
            autoFocus: false,
            path: "/lib/editor.md/lib/",
            toolbarIcons: function () {
                return ["bold", "italic", "|", "quote", "list-ul", "list-ol", "|", "link", "image", "|", "preview"]
            },
            placeholder: "",
            watch: false
        });

        /*
        // or
        testEditor = editormd({
            id      : "test-editormd",
            width   : "90%",
            height  : 640,
            path    : "../lib/"
        });
        */
    });
</script>
